import qs from "qs";
const baseURL = "http://qf.fsdy.learv.com";
export const request = <T = any>(
  path: string,
  options: REQUEST.Options
): Promise<T> => {
  const { method = "GET", headers = {}, body = {}, params = {} } = options;
  return fetch(baseURL + path + "?" + qs.stringify(params), {
    method,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
      ...headers,
    },
    body: Object.keys(body).length ? qs.stringify(body) : null,
  }).then((res) => res.json());
};

// 知识点1
// const data: Promise<number> = new Promise((resolve, reject) => {
//   resolve(666);
// });

// 知识点2
// function fn(data: string) {
// function fn(data: string | number) {
// function fn<T>(data: T) {
// function fn<T>(data: T):string {
// function fn<T>(data: T): Promise<T> {
//   console.log(data);
//   return new Promise(() => {});
// }
// fn<string>("111");
// fn<number>(222);
// fn<number[]>([]);

// ref<string>()
// useState<string>()
